import 'package:flutter_eve_plugin/store/base_action.dart';
import 'package:flutter_eve_plugin/store/ye_xiu/checkpoint/main.dart';
import 'package:redux/redux.dart';
import 'constant.dart';

CheckpointState checkpointReducer(CheckpointState state, action) {
  if (!(action is BaseAction)) {
    return state;
  }
  BaseAction baseAction = action;
  switch (action.type) {
    case PREPARE_GAME_SELECT_MAP:
      action.data?.forEach((key, value) {
        state.selectMap[key] = value;
      });
      return state.copyWith(selectMap: state.selectMap);
    case PREPARE_GAME_INDEX:
      return state.copyWith(selectKey: baseAction.data);
    case CHECKPOINT_DUNGEONS_INFO:
      return state.copyWith(checkpointDungeons: baseAction.data);
    case CHECKPOINT_STAGEID:
      return state.copyWith(dungeonid: baseAction.data);
    case CHECKPOINT_STAGES:
      return state.copyWith(checkpointStages: baseAction.data);
    case CHECKPOINT_STAGE_INFO:
      return state.copyWith(checkpointStageInfo: baseAction.data);
    case CHECKPOINT_RANK:
      return state.copyWith(dungeonRank: baseAction.data);
    case CHECKPOINT_VITALITY:
      return state.copyWith(dungeonVitality: baseAction.data);
    case CHECKPOINT_USERCARD:
      return state.copyWith(userCard: baseAction.data);
    case CHECKPOINT_FIGHT_SUCC:
      return state.copyWith(fightSucc: baseAction.data);
  }
  return state;
}

// ignore: non_constant_identifier_names
final CheckpointReducer = combineReducers<CheckpointState>([checkpointReducer]);
